import service from './service.js'

export default (url, method, params) => {
  uni.showLoading({
    title: "加载中"
  });
  
  const config = {
    baseUrl: 'https://bird.ioliu.cn/'
  }
  
  const api = service.filter(item => {
    return item.url == url;
  });
  
  return new Promise((resolve, reject) => {
    uni.request({
      url: config.baseUrl + url,
      method: method,
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        ...params
      },
      success(res) {
        resolve(res.data);
      },
      fail(err) {
        reject(err);
      },
      complete() {
        uni.hideLoading();
      }
    })
  })
}